import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PartnerTypeVO, PartnerTypeForm, PartnerTypeQuery } from '@/api/germbank/partner/partner/types';

/**
 * 查询商业伙伴管理列表
 * @param query
 * @returns {*}
 */

export const listPartner = (query?: PartnerTypeQuery): AxiosPromise<PartnerTypeVO[]> => {
  return request({
    url: '/germbank/partners/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询商业伙伴管理详细
 * @param id
 */
export const getPartner = (id: string | number): AxiosPromise<PartnerTypeVO> => {
  return request({
    url: '/germbank/client/' + id,
    method: 'get'
  });
};

/**
 * 新增商业伙伴管理
 * @param data
 */
export const addPartner = (data: PartnerTypeForm) => {
  return request({
    url: '/germbank/client',
    method: 'post',
    data: data
  });
};

/**
 * 修改商业伙伴管理
 * @param data
 */
export const updatePartner = (data: PartnerTypeForm) => {
  return request({
    url: '/germbank/client',
    method: 'put',
    data: data
  });
};

/**
 * 删除商业伙伴管理
 * @param id
 */
export const delPartner = (id: string | number | Array<string | number>) => {
  return request({
    url: '/germbank/client/' + id,
    method: 'delete'
  });
};

/**
 * 状态修改
 * @param clientId 商业伙伴id
 * @param status 状态
 */
export function changeStatus(clientId: string, status: string) {
  const data = {
    clientId,
    status
  };
  return request({
    url: '/germbank/client/changeStatus',
    method: 'put',
    data: data
  });
}

// 刷新联系我们缓存
export function refreshCache() {
  return request({
    url: '/system/dict/type/refreshCache',
    method: 'delete'
  });
}
